package ink.yql.dao;

import ink.yql.model.LeaveaMessage;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author YQL
 */
@Mapper
public interface LeaveaMessageDao {

    @Select("select * from leavea_message where otherid=#{otherid} and ltype = #{ltype} ")
    List<LeaveaMessage> getByOtheridAndLtype(@Param("otherid") Integer otherid, @Param("ltype") Integer ltype);

    @Delete("delete from leavea_message where otherid=#{otherid} and ltype = #{ltype} ")
    Integer deleteByOtheridAndLtype(@Param("otherid") Integer otherid, @Param("ltype") Integer ltype);

    @Delete("delete from leavea_message where luid=#{luid} and ltype = #{ltype} ")
    Integer deleteByUidAndLtype(@Param("luid") Integer luid, @Param("ltype") Integer ltype);

    @Delete("delete from leavea_message where lid=#{lid}")
    Integer deleteByLid(@Param("lid") Integer lid);

    @Select("select * from leavea_message where luid=#{luid} and ltype = #{ltype} ")
    List<LeaveaMessage> getByLuidAndLtype(@Param("luid") Integer luid, @Param("ltype") Integer ltype);

    @Insert("insert into leavea_message (luid,lcontext,ltype,otherid,laddTime)values " +
              "(#{luid} ),#{lcontext} ,#{ltype} ,#{otherid} ,#{laddTime} ")
    Integer addOne(LeaveaMessage leaveaMessage);

}
